package com.explorati.interview.interview.chaptersix;

import java.io.File;
import java.io.IOException;

public class FileDirTest {

	private static void DirMethod(File dir) {
		String[] files = dir.list();
		for (String fileName : files) {
			File f = new File(dir.getPath() + File.separator + fileName);
			if (f.isFile()) {
				System.out.println("file : " + f.getPath());
			} else if (f.isDirectory()) {
				DirMethod(f);
			}
		}
	}

	public static void main(String[] args) {
		File file1 = new File("e:/test/a.txt");
		if (!file1.exists()) {
			try {
				file1.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		File dir = new File("e:/test");
		if (dir.isDirectory()) {
			DirMethod(dir);
		}
	}
}
